<template>
	<z-paging ref="pagingRef" refresher-only @onRefresh="onRefresh">
		<view class="select-bank-list">
			<view class="select-bank-list-cell" v-for="item in dataList" :key="item.bankBranchNo" @tap="didSelectItem(item)">
				<image :src="item.bankBranchImage" mode="aspectFit"></image>
				<text>{{item.bankBranchName}}</text>
			</view>
			<xh-empty :show="dataList.length == 0"></xh-empty>
		</view>
	</z-paging>
	
</template>

<script setup>
	import { onLoad } from '@dcloudio/uni-app'
	import { ref } from 'vue'
	import { getBankList } from '@/common/api/api.js'
	import { useFormStore } from '@/common/stores'
	const formStore = useFormStore()
	const dataList = ref([])
	const pagingRef = ref(null)
	
	// 获取列表数据
	const onRefresh = async () => {
		const res = await getBankList()
		dataList.value = res.result
		pagingRef.value.complete()
	}
	// 选择银行
	const didSelectItem = (item)=>{
		formStore.bankBranchName = item.bankBranchName
		formStore.bankBranchNo = item.bankBranchNo
		formStore.bankIcon = item.bankBranchImage
		formStore.bankName = ''
		formStore.bankNo = ''
		uni.navigateBack()
	}
	onLoad(()=>{
		onRefresh()
	})
</script>

<style lang="scss" scoped>
.select-bank-list{
	padding: 30rpx;
	.select-bank-list-cell{
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 20rpx 30rpx;
		border-radius: 16rpx;
		margin-bottom: 20rpx;
		image{
			width: 68rpx;
			height: 68rpx;
			margin-right: 20rpx;
		}
		
	}
}
</style>
